package edu.towson.cosc603.coffeemaker;

import static org.junit.Assert.*;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class InventoryTest {
	
	Inventory inventory;

	@Before
	public void setUp() throws Exception {
		inventory = new Inventory();
	}

	@After
	public void tearDown() throws Exception {
	}

	@Test
	public void testInventory() {
		inventory = new Inventory();
		inventory.setChocolate(5);
		inventory.setCoffee(5);
		inventory.setMilk(5);
		inventory.setSugar(5);
	}

	@Test
	public void testGetChocolate() {
		assertEquals(15, inventory.getChocolate());
	}

	@Test
	public void testSetChocolate() {
		inventory.setChocolate(3);
		assertEquals(3, inventory.getChocolate());
	}
	
	@Test
	public void testSetChocolateFail() {
		inventory.setChocolate(-1);
		assertEquals(0, inventory.getChocolate());
	}

	@Test
	public void testGetCoffee() {
		assertEquals(15, inventory.getCoffee());
	}

	@Test
	public void testSetCoffee() {
		inventory.setCoffee(3);
		assertEquals(3, inventory.getCoffee());
	}
	
	@Test
	public void testSetCoffeeFail() {
		inventory.setCoffee(-3);
		assertEquals(0, inventory.getCoffee());
	}

	@Test
	public void testGetMilk() {
		assertEquals(15, inventory.getMilk());
	}

	@Test
	public void testSetMilk() {
		inventory.setMilk(3);
		assertEquals(3, inventory.getMilk());
	}
	
	@Test
	public void testSetMilkFail() {
		inventory.setMilk(-3);
		assertEquals(0, inventory.getMilk());
	}

	@Test
	public void testGetSugar() {
		assertEquals(15, inventory.getSugar());
	}

	@Test
	public void testSetSugar() {
		inventory.setSugar(3);
		assertEquals(3, inventory.getSugar());
	}
	
	@Test
	public void testSetSugarFail() {
		inventory.setSugar(-3);
		assertEquals(0, inventory.getSugar());
	}

	@Test
	public void testEnoughIngredients() {
		Recipe recipe = new Recipe();
		recipe.setAmtChocolate(5);
		recipe.setAmtCoffee(3);
		recipe.setAmtMilk(5);
		recipe.setAmtSugar(5);
		
		assertEquals(true, inventory.enoughIngredients(recipe));
		
	}
	
	@Test
	public void testEnoughIngredientsFailChocolate() {
		Recipe recipe = new Recipe();
		recipe.setAmtChocolate(25);
		recipe.setAmtCoffee(3);
		recipe.setAmtMilk(5);
		recipe.setAmtSugar(5);
		
		assertEquals(false, inventory.enoughIngredients(recipe));
		
	}
	
	@Test
	public void testEnoughIngredientsFailCoffee() {
		Recipe recipe = new Recipe();
		recipe.setAmtChocolate(5);
		recipe.setAmtCoffee(30);
		recipe.setAmtMilk(5);
		recipe.setAmtSugar(5);
		
		assertEquals(false, inventory.enoughIngredients(recipe));
		
	}
	
	@Test
	public void testEnoughIngredientsFailMilk() {
		Recipe recipe = new Recipe();
		recipe.setAmtChocolate(5);
		recipe.setAmtCoffee(3);
		recipe.setAmtMilk(50);
		recipe.setAmtSugar(5);
		
		assertEquals(false, inventory.enoughIngredients(recipe));
		
	}

	@Test
	public void testEnoughIngredientsFailSugar() {
		Recipe recipe = new Recipe();
		recipe.setAmtChocolate(5);
		recipe.setAmtCoffee(3);
		recipe.setAmtMilk(5);
		recipe.setAmtSugar(50);
		
		assertEquals(false, inventory.enoughIngredients(recipe));
		
	}
	
	@Test
	public void testToString() {
		inventory.toString();
	}

}
